package com.pctc.controller;

import com.pctc.model.User;
import com.pctc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping("/getUser")
    public User getUser(Integer id){
       return userService.findById(id);
    }



    @RequestMapping("/insertUser")
    public int insertUser(User user){
        return userService.insert(user);
    }


    @RequestMapping(value = "/insertUser1",method = RequestMethod.POST)
    public int insertUser1(User user){
        return userService.insert(user);
    }

    @RequestMapping("/getUsers")
    public List<User> getUsers(String name){
        return  userService.findByName(name);
    }



}
